#!/bin/sh
#
# /etc/rc.d/rc.watchdog
#
# Start/stop/restart the watchdog timer service.

watchdog_start() {
  if [ ! -e /dev/watchdog ]; then
    echo "$0: No /dev/watchdog device node seems to exist on this system."
    echo "$0: A kernel module probably needs to be loaded; please see:"
    echo "$0: /usr/src/linux/Documentation/watchdog/watchdog-api.txt"
    exit 0
  fi
  if [ -x /usr/sbin/watchdog -a -r /etc/watchdog.conf ]; then
    echo "Starting the watchdog timer service:  /usr/sbin/watchdog"
    /usr/sbin/watchdog
  fi
}

watchdog_stop() {
  killall watchdog
}

watchdog_restart() {
  watchdog_stop
  sleep 10 # can take a while to die
  watchdog_start
}

case "$1" in
'start')
  watchdog_start
  ;;
'stop')
  watchdog_stop
  ;;
'restart')
  watchdog_restart
  ;;
*)
  echo $"Usage: $0 {start|stop|restart}"
esac

